<template>
  <draggable class="pure-menu-list" tag="div" v-model="list" v-bind="dragOptions" @start="drag = true"
    @end="drag = false">
    <div class="nav-item" v-for="element in list" :key="element.name">
      <span>{{ element.name }}</span>
      <span>{{ element.label }}</span>
    </div>
  </draggable>
</template>
<script>
import { defineComponent } from 'vue'
import { VueDraggableNext } from 'vue-draggable-next'
export default defineComponent({
  components: {
    draggable: VueDraggableNext,
  },
  data() {
    return {
      enabled: true,
      list: [
        { name: 'radio', label: '单选框' },
        { name: 'checkbox', label: '多选框' },
        { name: 'input', label: '输入框' },
        { name: 'inputNumber', label: '计数器' },
        { name: 'select', label: '选择器' },
        { name: 'cascader', label: '级联选择器' },
        { name: 'switch', label: '开关' },
        { name: 'slider', label: '滑块' },
        { name: 'timePicker', label: '时间选择器' },
        { name: 'datePicker', label: '日期选择器' },
        { name: 'dateTimePicker', label: '日期时间选择器' },
        { name: 'upload', label: '上传' },
        { name: 'rate', label: '评分' },
        { name: 'colorPicker', label: '颜色选择器' },
        { name: 'transfer', label: '穿梭框' },
        { name: 'form', label: '表单' }
      ],
      dragging: false,
    }
  },
  computed: {
    dragOptions() {
      return {
        animation: 200,
        group: "description",
        disabled: false,
        ghostClass: "ghost"
      };
    }
  },
  methods: {
    log(event) {
      console.log(event)
    },
  },
})
</script>
<style lang="less" scoped>
.pure-menu-list {
  display: flex;
  flex-wrap: wrap;
  padding-bottom: 20px;

  .nav-item {
    width: 100px;
    border: 1px solid #eee;
    margin-left: 10px;
    margin-top: 10px;
    font-size: 12px;
    text-align: center;
    padding: 5px 0;

    span {
      display: block;
    }

    span:nth-child(0) {
      opacity: 0.8;
      transform: scale(0.8);
    }
  }
}
</style>